/** 
* All Rights Reserved , Copyright (C) 2022 , 青岛鼎信通讯股份有限公司
* 
* MpmProjectBidDateService
* 项目立项-挂网开标日期
* 
* 修改纪录
* 2022-01-20 版本：1.0 houyuhang 创建。
* @version 版本：1.0
* @author 作者：houyuhang
* 创建日期：2022-01-20
*/
package com.topscomm.mpm.service.impl;

import com.topscomm.basic.BasicEntity;
import com.topscomm.mpm.pojo.MpmProjectBidDateEntity;
import com.topscomm.mpm.pojo.MpmProjectSaleEntity;
import com.topscomm.pub.util.ConvertUtil;
import com.topscomm.pub.util.StringBufferProxy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.topscomm.mpm.service.IMpmProjectBidDateService;
import com.topscomm.mpm.service.impl.auto.MpmProjectBidDateServiceAuto;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service(value = "mpmProjectBidDateService")
@Scope(value = "singleton")
public class MpmProjectBidDateService extends MpmProjectBidDateServiceAuto implements IMpmProjectBidDateService {
    /**
     * @Title: removeAndAddBidDate
     * @description: 新增或更新挂网开标日期信息记录
     * @param
     * @return
     * @author: houyuhang
     * @date: 2022-01-21
     * @modify:
     */
    public void removeAndAddBidDate(Object object,long id) {
        if(id == 0) {
            return;
        }
        if(object == null) {
            return;
        }
        // 删除原挂网开标日期
        StringBufferProxy sql = new StringBufferProxy();
        sql.appendSingle(" {0} = '{1}' ", MpmProjectBidDateEntity.FieldProjectid, id);
        this.deleteByWhere(sql.toString());
        // 生成挂网开标日期
        List<Map<String,Object>> bidDateList = (List<Map<String,Object>>) object;
        List<BasicEntity> basicEntities = new ArrayList<>();
        for(Map<String,Object> bidDate : bidDateList) {
            MpmProjectBidDateEntity mpmProjectBidDateEntity = new MpmProjectBidDateEntity();
            mpmProjectBidDateEntity.convertFromMap(bidDate);
            mpmProjectBidDateEntity.setProjectid(id);
            basicEntities.add(mpmProjectBidDateEntity);
        }
        this.insertBatch(basicEntities);
    }
}
